package com.ruoyi.web.controller.tool;

import java.util.*;


import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.web.core.domain.Users;
import com.ruoyi.web.mapper.UserMysqlMapper;
import com.ruoyi.web.mapper.UserPgSqlMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

/**
 * swagger 用户测试方法
 * 
 * @author ruoyi
 */
@Api("用户信息管理")
@Slf4j
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController {

    @Resource
    private UserMysqlMapper userMysqlMapper;

    @Resource
    private UserPgSqlMapper userPgSqlMapper;

    @ApiOperation("获取用户列表")
    @GetMapping("/list")
    @Anonymous
    @Transactional(rollbackFor = Exception.class)
    public R<List<Users>> userList()
    {
        /*List<Users> mysqlUsers = userMysqlMapper.queryUsers();
        log.info("查看主库的查询数据：{}", JSON.toJSONString(mysqlUsers));

        List<Users> pgUsers = userPgSqlMapper.queryUsers();
        log.info("查看从库的查询数据：{}", JSON.toJSONString(pgUsers));*/
        userMysqlMapper.insertMysqlUser(new Users("xbhogMysql", "111111", "2251195014@qq.com", "衣立君", "18453574212", new Date(),new Date()));
        userPgSqlMapper.insertPgsqlUser(new Users("xbhogPgsql", "111111", "xxxxx@qq.com", "衣立君", "18453574212", new Date(),new Date()));
       /* if(1==1){
            throw new RuntimeException("测试事务");
        }*/
        return R.ok();
    }
}

